<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>axios创建实例对象</title>
    <script crossorigin="anonymous" src="https://cdn.bootcss.com/axios/0.19.2/axios.min.js"></script>
</head>
<body>
    <script>

        // axios({
        //     method:"GET",
        //     url: 'http://a.com/server',
        //     timeout: 3000
        // })

        // axios({
        //     method:"GET",
        //     url: 'http://a.com/login',
        //     timeout: 3000
        // })

        // axios({
        //     method:'post',
        //     url:'http://b.com/server',
        //     timeout: 3000
        // })

        //创建实例对象
        //参数是一个『配置对象』
        let duanzi = axios.create({
            method:"GET",
            baseURL: 'https://api.apiopen.top/',
            timeout: 3000
        });

        let tianqi = axios.create({
            method:"GET",
            baseURL: 'https://www.tianqiapi.com/',
            timeout: 3000
        });

        //使用实例对象发送请求, 使用方式与 axios 使用方式相同
        // duanzi.get
        duanzi({
            url:'/getJoke'
        }).then(response => {
            console.log(response);
        });

    </script>
</body>
</html>